package com.ruifu.worksheet.controller;

import com.fhzncloud.cloud.common.security.service.CloudUser;
import com.fhzncloud.cloud.common.security.util.SecurityUtils;
import com.ruifu.common.vo.worksheet.WsCommonSheet;
import com.ruifu.worksheet.service.WsRelationFunctionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigInteger;
import java.util.List;

/**
 * @author yuanyundi
 * @date 2020/04/20
 */
@RestController
@CrossOrigin
@Slf4j
@RequestMapping("/wsRelationFunction")
public class WsRelationFunctionController {
    @Autowired
    private WsRelationFunctionService wsRelationFunctionService;

    /**
     * 用于存储登陆人信息
     */
    private CloudUser cloudUser;

    /**
     * 通过url请求方法之前,调用该方法获取登陆人信息
     */
    @ModelAttribute
    public void before() {
        cloudUser = SecurityUtils.getUser();
    }

    /**
     *
     * @param relationId
     * @param busiFlag
     * @return
     */
    @GetMapping(value = "findRelationWs/{relationId}/{busiFlag}")
    public List<WsCommonSheet> findRelationWs(@PathVariable("relationId")BigInteger relationId,
                                              @PathVariable("busiFlag") String busiFlag){
       return wsRelationFunctionService.findRelationWs(relationId,busiFlag);
    }
}
